{/* LAYOUT模板 */}
	<layout name="layout"/>
{/* LAYOUT模板 */}

<!-- [position] -->
	<include file="Template:position"/>
<!-- [position] -->

<div class="mauto">		
	<form name="tagform" action="__APP__/Course/addtagOk" method="post">
		<table width="100%" id="mytab"  border="1" class="t1">		
		  <tr>
			<td align="right" width="30%">{$lang.tag_name}</td>
			<td align="left">
				<input type="text" class="input" style="width:160px;" name="tag_name"/>
				<span class="redtext">*</span>
			</td>
		  </tr>	
		  <tr>
			<td align="right">{$lang.search_course}</td>
			<td align="left" height="100">
				<span><input id="search" type="text" class="input" style="width:160px;" value="" style="color:#a0a0a0;" /></span>
				<span><input type="button"  onclick="searchcourse();" value="{$lang.search}" style="width:50px;"/></span>
				<span><input type="button"  onclick="searchcourse();" value="{$lang.all_course}" style="width:70px;"/></span>
			</td>
		  </tr>
		  <tr>
			<td align="right">{$lang.course_name}</td>
			<td align="left">
				<select id="courselist" class="input" style="width:160px;" name="course_id" value="">
					<option>{$lang.please_select_course}</option>
					<option id="repeatHTML" class="repeatHTML hide">							
					</option>
				</select>
			</td>
		  </tr>
		  <tr>
			<td align="right">{$lang.tag_hot}</td>
			<td align="left">
				<input type="text" name="hot" class="input" style="width:160px;" value=""/>{$lang.tag_hot_format}
			</td>
		  </tr>
		  <tr>
			<td colspan="2" align="center">
				<input type="submit" style="width:50px;" value="{$lang.submit_text}"/>
			</td>
		  </tr>
		</table>
	</form>
</div>


<script>
	//替换数据的对象
	var htmlReplace      =   new Object;
	
	htmlReplace.replace  = function(datas){
		if(typeof datas == 'undefined')datas = {};
		if(typeof datas == null) datas = {};
		//移除className=value
		var _parent      =   $('#courselist');//转换对象
		
		//移除class=value
		var optArr       =   _parent.find('option');
		for(var n in optArr){
			if(optArr[n].className == "value") $(optArr[n]).remove();
		}				
		
		for(var i in datas){
			var data = datas[i];
			var tp   = $("<option>");
			//alert(data['course_name']);
			for(var j in data){
				if(j == 'course_id') tp.attr('value',data[j]).attr('class','value');
				if(j == 'course_name') tp.text(data[j]);
			}
			_parent.find('.repeatHTML').after(tp);
		}		
	}

	//搜索课程名字
	function searchcourse(){
		var courseListObj    =   document.getElementById("courselist");
		var repeatObj        =   document.getElementById("repeatHTML");
		var searchObj        =   document.getElementById('search');
		var v                =   searchObj.value;
		var html             =   "";
		//ajax
		var opt = {
			url:'__APP__/Course/searchcourse',
			data:{key:v},
			type:'post',
			dataType:'json',
			success:function(msg){
				htmlReplace.replace(msg.data);				
			}
		}
		$.ajax(opt);
	}	
</script>
